<?php
/**
* Admin for CMS settings
*
* @author Mario Schillermann <info@rockit-flash.com>
* @encoding UTF-8 äöüßÖÄÜ
* @copyright © 2011 Mario Schillermann (info@rockit-flash.com)
* @license GNU GPL v2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
* @package Page
* @subpackage Index
* @link $HeadURL$
* @version SVN: $Id$
* @phpVersion >=5
* @todo
*/

class Access_Form_Access extends Zend_Form {
    /**
     * Index
     *
     * @return void $head
     */
    public function build(array $roles, array $permission)
    {

        $this->setName('access');
        $this->addElement(
            new Zend_Form_Element_Select(
                'rolelist', array('label' => 'Rollen')
            )
        );
       
      /*  
         $this->addElement(new Zend_Form_Element_Checkbox(
            'test2', array('label' => 'test2')));
        
        $this->rolelist->addMultiOptions($roles);
  // var_dump($permission);   
        foreach($permission as $module => $data) {
            
            $this->addElement(new Zend_Form_Element_Text(
            $module, array('label' => $data['app']['name'])));
            
            
            
            if(isset($data['access'])) {
                foreach($data['access'] as $language => $controller) {
                    
                    
                    foreach($controller as $name => $action) {
                        echo "Name: ".$name;
                        echo "Action: " . $action;
                        break;
                    }
                    
                 
                $this->addDisplayGroup(
                    array('test2'),
            $module,
            array("legend" => $controller['app']['name']));
            }
                    
                    break;
                }
            }
            var_dump($data);
            
             break;
/*
            if(isset($data['access'])) {
            foreach($data['access'] as $language => $controller) {
                $test = array();
                foreach($controller as $name => $action) {
                    
                    $this->addElement(
                        new Zend_Form_Element_Checkbox(
                            $action, array('label' => $name)));
                    //$test[] = $action;
                }
                break;
            }
            }
            /*
            $this->addDisplayGroup(
            array(
                $module
            ),
            $test,
            array("legend" => "test"));
        }
        */

        $this->addElement(new Zend_Form_Element_Checkbox(
            'title', array('label' => 'index')));
        $this->addElement(new Zend_Form_Element_Checkbox(
            'author', array('label' => 'save')));

        //$this->username->addValidator('regex', false, array('/^[a-z]/i'));
/*
        $this->title->setValue($head->title);
        $this->author->setValue($head->meta->author);
        $this->keywords->setValue($head->meta->keywords);
        $this->description->setValue($head->meta->description);
        $this->text->setValue($content);
*/ 
        
        
        $this->addDisplayGroup(
            array(
                'rolelist'
            ),
            'roles',
            array("legend" => ""));
        
        $this->addDisplayGroup(
            array(
                'title',
                'author',
            ),
            'groups',
            array("legend" => "Minipage"));

        return $this;

    }

}